package org.loong.crypto.extension.operator;

import java.security.Key;

import org.bouncycastle.operator.GenericKey;

public class OperatorUtils {

    public static byte[] getKeyBytes(GenericKey key) {
        if (key.getRepresentation() instanceof Key) {
            return ((Key) key.getRepresentation()).getEncoded();
        } else if (key.getRepresentation() instanceof byte[]) {
            return (byte[]) key.getRepresentation();
        } else {
            throw new IllegalArgumentException("unknown generic key type");
        }
    }
}
